package classesInterface;

import classesBancodeDados.FichaLaudoAutorInternHosp;
import classesBancodeDados.Paciente;
import classesBancodeDados.Pessoa;
import classesJpa.FichaLaudoAutorInternHospJpaController;
import classesJpa.exceptions.NonexistentEntityException;
import classesMiolo.Formatador;
import classesMiolo.MapasLaudoAutorInternHosp;
import classesMiolo.ReverseMapper;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;

public class TelaFichaLaudoSolicitacaoAutorizacao3 extends javax.swing.JFrame {

    /**
     * Creates new form LaudoAutorizacao3
     */
    private TelaFichaLaudoSolicitacaoAutorizacao3() {   
        initComponents();
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    
    private static TelaFichaLaudoSolicitacaoAutorizacao3 uniqueInstance = null;
    
    public static TelaFichaLaudoSolicitacaoAutorizacao3 getInstance(){
        if(uniqueInstance == null){
            uniqueInstance = new TelaFichaLaudoSolicitacaoAutorizacao3();
        }
        return uniqueInstance;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        campoDescricao = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        campoProced = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        campoClinica = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        campoCarater = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        campoCpfSolicitante = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        campoProfSolicitante = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        campoDataSolicitacao = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        comboAcidente = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        campoCnpj = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        campoBilhete = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        campoSerie = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        campoCnae = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        campoCbor = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        comboVinculo = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel18 = new javax.swing.JLabel();
        campoNome = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        campoOrgao = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        campoCpfProf = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        campoAutor = new javax.swing.JTextField();
        botaoSalvar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel1.setText("Procedimento Solicitado");

        jLabel2.setText("Descrição do Procedimento Solicitado:");

        jLabel3.setText("Código do Procedimento:");

        jLabel4.setText("Clínica:");

        jLabel5.setText("Caráter da Internação:");

        jLabel6.setText("CPF do Profissional Solicitante:");

        campoCpfSolicitante.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoCpfSolicitanteKeyPressed(evt);
            }
        });

        jLabel7.setText("Nome do Profissional Solicitante:");

        jLabel8.setText("Data Solicitação:");

        campoDataSolicitacao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoDataSolicitacaoKeyPressed(evt);
            }
        });

        jLabel9.setText("Preencher em Casos de Causas Externas (Violências ou Acidentes)");

        jLabel10.setText("Tipo de Acidente:");

        comboAcidente.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Acidente de Trânsito", "Acidente de Trabalho Típico", "Acidente de Trabalho Trajeto" }));

        jLabel11.setText("CNPJ da Seguradora:");

        jLabel12.setText("Nº do Bilhete:");

        jLabel13.setText("Série:");

        jLabel15.setText("CNAE da Empresa:");

        jLabel16.setText("CBOR:");

        jLabel17.setText("Vínculo com a previdência:");

        comboVinculo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Empregado", "Empregador", "Autônomo", "Desemprego", "Aposentado", "Não Segurado" }));

        jLabel14.setText("Autorização");

        jLabel18.setText("Nome do Profissional Autorizador:");

        jLabel19.setText("Código do Órgão Emissor:");

        jLabel20.setText("CPF do Profissional Utilizador:");

        campoCpfProf.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoCpfProfKeyPressed(evt);
            }
        });

        jLabel21.setText("Data da Autorização:");

        campoAutor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoAutorKeyPressed(evt);
            }
        });

        botaoSalvar.setText("Salvar");

        jButton1.setText("< Anterior");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton3.setText("Cancelar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator1)
                            .addComponent(jSeparator2)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 536, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 64, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoProced, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoClinica))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoCarater)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoCpfSolicitante, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoCnpj))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboAcidente, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoCnae, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoCbor)
                                .addContainerGap())
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoBilhete, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoSerie)
                                .addGap(12, 12, 12))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoProfSolicitante, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoDataSolicitacao))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel9)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel17)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(comboVinculo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(12, 12, 12))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jSeparator3)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel18)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoNome)))
                        .addGap(12, 12, 12))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel19)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoOrgao, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel20)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoCpfProf)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoAutor)
                        .addContainerGap())))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botaoSalvar)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(campoDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(campoProced, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(campoClinica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(campoCarater, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(campoCpfSolicitante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(campoProfSolicitante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(campoDataSolicitacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(comboAcidente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(campoBilhete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(campoSerie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(campoCnpj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(campoCnae, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(campoCbor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(comboVinculo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(campoNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(campoOrgao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21)
                    .addComponent(campoAutor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(campoCpfProf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoSalvar)
                    .addComponent(jButton1)
                    .addComponent(jButton3))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        this.setVisible(false);
        TelaFichaLaudoSolicitacaoAutorizacao2.getInstance().setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void campoCpfSolicitanteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoCpfSolicitanteKeyPressed
        if(evt.getKeyChar() != '\b'){
            this.campoCpfSolicitante.setText(Formatador.formataCPF(this.campoCpfSolicitante.getText()));
        }
    }//GEN-LAST:event_campoCpfSolicitanteKeyPressed

    private void campoCpfProfKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoCpfProfKeyPressed
        if(evt.getKeyChar() != '\b'){
            this.campoCpfProf.setText(Formatador.formataCPF(this.campoCpfProf.getText()));
        }
    }//GEN-LAST:event_campoCpfProfKeyPressed

    private void campoAutorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoAutorKeyPressed
        if(evt.getKeyChar() != '\b'){
            campoAutor.setText(Formatador.formataData(campoAutor.getText()));
        }
    }//GEN-LAST:event_campoAutorKeyPressed

    private void campoDataSolicitacaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoDataSolicitacaoKeyPressed
        if(evt.getKeyChar() != '\b'){
            campoDataSolicitacao.setText(Formatador.formataData(campoDataSolicitacao.getText()));
        }
    }//GEN-LAST:event_campoDataSolicitacaoKeyPressed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        TelaFichaLaudoSolicitacaoAutorizacao.getInstance().limpaCampos();
        TelaFichaLaudoSolicitacaoAutorizacao2.getInstance().limpaCampos();
        TelaFichaLaudoSolicitacaoAutorizacao3.getInstance().limpaCampos();
        setVisible(false);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        TelaFichaLaudoSolicitacaoAutorizacao.getInstance().limpaCampos();
        TelaFichaLaudoSolicitacaoAutorizacao2.getInstance().limpaCampos();
        TelaFichaLaudoSolicitacaoAutorizacao3.getInstance().limpaCampos();
    }//GEN-LAST:event_formWindowClosing

    public void limpaCampos(){
        campoAutor.setText("");
        campoBilhete.setText("");
        campoCarater.setText("");
        campoCbor.setText("");
        campoClinica.setText("");
        campoCnae.setText("");
        campoCnpj.setText("");
        campoCpfProf.setText("");
        campoCpfSolicitante.setText("");
        campoDataSolicitacao.setText("");
        campoDescricao.setText("");
        campoNome.setText("");
        campoOrgao.setText("");
        campoProced.setText("");
        campoProfSolicitante.setText("");
        campoSerie.setText("");
    }
    
    public void turnEditable(boolean editable){
        campoAutor.setEditable(editable);
        campoBilhete.setEditable(editable);
        campoCarater.setEditable(editable);
        campoCbor.setEditable(editable);
        campoClinica.setEditable(editable);
        campoCnae.setEditable(editable);
        campoCnpj.setEditable(editable);
        campoCpfProf.setEditable(false);
        campoCpfSolicitante.setEditable(false);
        campoDataSolicitacao.setEditable(editable);
        campoDescricao.setEditable(editable);
        campoNome.setEditable(false);
        campoOrgao.setEditable(editable);
        campoProced.setEditable(editable);
        campoProfSolicitante.setEditable(false);
        campoSerie.setEditable(editable);
        comboAcidente.setEnabled(editable);
        comboVinculo.setEnabled(editable);
    }
    
    public void preencherCampos(Paciente p, Pessoa prof, Pessoa solic, FichaLaudoAutorInternHosp laih){
        this.campoAutor.setText(laih.getAutorizador());
        this.campoBilhete.setText(laih.getnBilhete());
        this.campoCarater.setText(laih.getCarater());
        this.campoCbor.setText(laih.getCbor());
        this.campoClinica.setText(laih.getClinica());
        this.campoCnae.setText(laih.getCnaeEmpresa());
        this.campoCnpj.setText(laih.getCnpjSeguradora());
        this.campoCpfProf.setText(prof.getCpf());
        this.campoCpfSolicitante.setText(solic.getCpf());
        this.campoDataSolicitacao.setText(laih.getDataSolicitacao());
        this.campoDescricao.setText(laih.getProcedimento());
        this.campoNome.setText(prof.getNome());
        this.campoOrgao.setText(laih.getCodOrgaoEmissor());
        this.campoProced.setText(laih.getCodigo());
        this.campoProfSolicitante.setText(solic.getNome());
        this.campoSerie.setText(laih.getSerie());
        MapasLaudoAutorInternHosp mlai = MapasLaudoAutorInternHosp.getInstance();
        this.comboAcidente.setSelectedItem(ReverseMapper.getKeyFromValue(mlai.getAcidento(), laih.getAcidente()));
        this.comboVinculo.setSelectedItem(ReverseMapper.getKeyFromValue(mlai.getVinculo(), laih.getVinculo()));
    }
    
    private void salvar(){
        ficha.setAutorizador(this.campoAutor.getText());
        ficha.setnBilhete(this.campoBilhete.getText());
        ficha.setCarater(this.campoCarater.getText());
        ficha.setCbor(this.campoCbor.getText());
        ficha.setClinica(this.campoClinica.getText());
        ficha.setCnaeEmpresa(this.campoCnae.getText());
        ficha.setCnpjSeguradora(this.campoCnpj.getText());
        ficha.setDataSolicitacao(this.campoDataSolicitacao.getText());
        ficha.setProcedimento(this.campoDescricao.getText());
        ficha.setCodOrgaoEmissor(this.campoOrgao.getText());
        ficha.setCodigo(this.campoProced.getText());
        ficha.setSerie(this.campoSerie.getText());
        
        FichaLaudoAutorInternHospJpaController laic = new FichaLaudoAutorInternHospJpaController(); 
        try {
            laic.edit(ficha);
        } catch (NonexistentEntityException ex) {
            Logger.getLogger(TelaFichaLaudoSolicitacaoAutorizacao3.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(TelaFichaLaudoSolicitacaoAutorizacao3.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public FichaLaudoAutorInternHosp getFicha() {
        return ficha;
    }

    public void setFicha(FichaLaudoAutorInternHosp ficha) {
        this.ficha = ficha;
    }   
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaFichaLaudoSolicitacaoAutorizacao3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaFichaLaudoSolicitacaoAutorizacao3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaFichaLaudoSolicitacaoAutorizacao3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaFichaLaudoSolicitacaoAutorizacao3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                TelaFichaLaudoSolicitacaoAutorizacao3.getInstance().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoSalvar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextField campoAutor;
    private javax.swing.JTextField campoBilhete;
    private javax.swing.JTextField campoCarater;
    private javax.swing.JTextField campoCbor;
    private javax.swing.JTextField campoClinica;
    private javax.swing.JTextField campoCnae;
    private javax.swing.JTextField campoCnpj;
    private javax.swing.JTextField campoCpfProf;
    private javax.swing.JTextField campoCpfSolicitante;
    private javax.swing.JTextField campoDataSolicitacao;
    private javax.swing.JTextField campoDescricao;
    private javax.swing.JTextField campoNome;
    private javax.swing.JTextField campoOrgao;
    private javax.swing.JTextField campoProced;
    private javax.swing.JTextField campoProfSolicitante;
    private javax.swing.JTextField campoSerie;
    private javax.swing.JComboBox comboAcidente;
    private javax.swing.JComboBox comboVinculo;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    // End of variables declaration//GEN-END:variables
    private FichaLaudoAutorInternHosp ficha;
}
